﻿using System;
using System.Windows.Forms;

namespace AlarmClock.UI
{
    public partial class FrmTools : Form
    {
        public FrmTools()
        {
            InitializeComponent();
            datePick.Date_Start.TextChanged += datePick_TimeChanged;
            datePick.Hour_Start.TextChanged += datePick_TimeChanged;
            datePick.Minute_Start.TextChanged += datePick_TimeChanged;
            datePick.Second_Start.TextChanged += datePick_TimeChanged;

            datePick.Date_End.TextChanged += datePick_TimeChanged;
            datePick.Hour_End.TextChanged += datePick_TimeChanged;
            datePick.Minute_End.TextChanged += datePick_TimeChanged;
            datePick.Second_End.TextChanged += datePick_TimeChanged;
        }

        /// <summary>
        /// 显示时间差
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void datePick_TimeChanged(object sender, EventArgs e)
        {
            txtWeeks.Text = (Math.Round(datePick.weeks, 2)).ToString();
            txtDays.Text = (Math.Round(datePick.days, 2)).ToString();
            txtHours.Text = (Math.Round(datePick.hours, 2)).ToString();
            txtMinutes.Text = (Math.Round(datePick.minutes, 2)).ToString();
            txtSeconds.Text = (Math.Round(datePick.seconds, 2)).ToString();
            txtMilliSeconds.Text = (Math.Round(datePick.milliSeconds, 2).ToString());
        }
    }
}
